/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * This file was generated form {{ Idlfilename }}.idl by the mvbs-idl-gen tool.
 */

{% import './general/typeMacros.jinja2' as Macros -%}
{% import './general/typeMacrosPro.jinja2' as MacrosPro -%}
{% import './general/typePluginMacros.jinja2' as PluginMacros -%}
{% import './general/typeRPC.jinja2' as RPC -%}

#ifndef {{ Idlfilename }}RpcParam_C
#define {{ Idlfilename }}RpcParam_C

#include <string.h>

#include <mvbs/utils/cdefs.h>

#include <mcdr/mcdr.h>

#include <mvbs/utils/string.h>
#include <mvbs/utils/mm.h>

#include "{{ Idlfilename }}RpcParams.h"

{%- for node in constructMapList_idl %}
/************************  {{node.nativeFQNameInModule}}  *************************/
{{ Macros.defineGetRpcTopicSize(node) }}

{{ Macros.defineTopicRpcSerialize(node) }}

{{ Macros.defineTopicRpcDeserialize(node) }}
{%- endfor %}


{%- for node in constructMapList %}
{%- for member in node.FuncMember %}

{%- if node.ModuleName -%}
	{% set interface_name = node.ModuleName ~ "_" ~ node.InterfaceName %}
{%- else -%}
	{% set interface_name = node.InterfaceName %}
{%- endif -%}

{%- set inputs = member.ParamIn | default([]) + member.ParamInout | default([]) -%}
{%- set outputs = member.ParamOut | default([]) + member.ParamInout | default([]) %}

{{ RPC.defineGetRpcBufferSize(interface_name, member, inputs) }}

/************************  {{interface_name}}_{{member.FuncName}}  *************************/
{%- if inputs != []%}
{{ RPC.InputsParamSerialize(interface_name, member, inputs)}}

{{ RPC.InputsParamDeserialize(interface_name, member, inputs)}}
{%- endif %}
{%- if outputs != []%}
{{ RPC.OutputsParamSerialize(interface_name, member, outputs)}}

{{ RPC.OutputsParamDeserialize(interface_name, member, outputs)}}
{%- endif %}
{%- endfor %}
{%- endfor %}

#endif /* {{ Idlfilename }}RpcParam_C */
